package com.ibangnuo.manage;

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: wwy
 * @Date: 2019-12-18 16:40
 */
@SpringBootApplication
@EntityScan("com.ibangnuo.framework.domain")
@ComponentScan(basePackages = {"com.ibangnuo.api"})
@ComponentScan(basePackages = {"com.ibangnuo.framework"})
@ComponentScan(basePackages = {"com.ibangnuo.manage"})
@EnableScheduling
public class ManageApplication {
    public static void main(String[] args) {
        SpringApplication.run(ManageApplication.class,args);
    }
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
    }
    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ClassPathResource("application-pay.yml"),new ClassPathResource("application-third-party.yml"),new ClassPathResource("application-upload.yml"),new ClassPathResource("application-wxpay.yml"));
        configurer.setProperties(yaml.getObject());
        return configurer;
    }
}
